<template>
  <div class="mod-config" style="padding-bottom: 10px;">
    <div class="app-title">
      <div style="float:left;padding: 10px;">{{title}}</div>
      <img class="avatar" :src="userInfo.avatar+'_60x60q90.jpg'" /><span style="font-size: 14px"> 你好， {{userInfo.realName}} </span>
    </div>
    <div class="pj_container">
      <keep-alive>
        <router-view></router-view>
      </keep-alive>
    </div>
    <div class="foot">
      <router-link to="/vote-setting">
        <div>
          <i class="el-icon-setting"></i><br>
          投票设置
        </div>
      </router-link>
      <router-link to="/vote-static">
        <div>
          <i class="el-icon-data-analysis"></i><br>
          统计查看
        </div>
      </router-link>
      <router-link to="/vote-history">
        <div>
          <i class="el-icon-document"></i><br>
          操作记录
        </div>
      </router-link>
    </div>
  </div>
</template>

<script>
  import dingMixin from  '@/mixins/ding'
  import * as dd from 'dingtalk-jsapi'

  export default {
    data () {
      return {
        title:'力沃投票管理'
      }
    },
    mixins: [dingMixin],
    created() {
      if (dd.env.platform!="notInDingTalk") {
        if(this.userInfo && this.userInfo.dingId && this.dingConfig.corpId && this.$cookie.get('token')>'') {
          return;
        }
        this.getDingConfig().then(config =>{
          this.dingConfig = config;
          this.dingLogin(config.corpId, null);
        })
      }
    },
    methods: {
    },
    watch:{
      '$route' (to, from){
        if(to.name=='vote-setting'){
          this.title='投票设置';
        }
        else if(to.name=='vote-static'){
          this.title='统计查看';
        }
        else if(to.name=='vote-history'){
          this.title='操作记录';
        }
      }
    }
  }
</script>

<style scoped>
  .avatar{
    width: 36px;
    height: auto;
    margin-right: 15px;
    border-radius: 100%;
    vertical-align: middle;
  }
  .app-title {
    z-index: 3;
    background: white;
    position: fixed;
    width:100%;
    top:0px;
    left:0px;
    padding:5px 10px;
    height:48px;
    font-size: 18px;
    text-align: right;
    border-bottom: lightgray solid 1px;
  }
  .pj_container{
    margin: 48px 0;
  }


  .foot{
    width:100%;
    height:48px;
    position: fixed;
    bottom:0px;
    left:0px;
    border-top: #bbb solid 1px;
    cursor:pointer;
    background: white;
    z-index: 9;
  }

  .foot div{
    float:left;
    height:48px;
    width:33%;
    padding:5px;
    text-align: center;
  }

  .router-link-exact-active{
    color: #67c23a;  /*lightgreen;*/
    font-weight: bold;
  }

</style>

